package bintree.heap;

import queue_stack.queue.Queue;

/**
 * 基于最小堆实现的优先级队列
 * @author yuisama
 * @date 2021/12/13 16:38
 **/
public class PriorityQueue<E extends Comparable<E>> implements Queue<E> {
    private final MinHeap<E> minHeap = new MinHeap<>();
    @Override
    public E dequeue() {
        return minHeap.extractMin();
    }

    @Override
    public E getFont() {
        return minHeap.getMin();
    }

    @Override
    public void enqueue(E e) {
        minHeap.add(e);
    }

    @Override
    public int getSize() {
        return minHeap.getSize();
    }

    @Override
    public boolean isEmpty() {
        return getSize() == 0;
    }
}